package com.yukong.web.config;

import com.yukong.web.filter.TimeFilter;
import com.yukong.web.interceptor.TimeInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Description:
 * User: xp
 * Date: 2018-01-04
 * Time: 14:04
 */
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter{


    @Autowired
    private TimeInterceptor timeInterceptor;

    /*@Bean
    public FilterRegistrationBean timeFilter(){
        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new TimeFilter());

        List<String> urls =  new ArrayList<>();

        urls.add("/*");
        registrationBean.setUrlPatterns(urls);

        return registrationBean;
    }*/


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //registry.addInterceptor(timeInterceptor);
    }
}
